import json
import pymongo

def response(flow):
    #获取深沪股票B的信息

    if 'node=hs_b' in flow.request.url:
        res = flow.response
        data = json.loads(res.text)['data']['list']
        if data:
            col = get_mongo_col('xinlang_app','hs_b')
            for item in data:
                col.insert(item)

def get_mongo_col(db,col):
    client=pymongo.MongoClient('mongodb://192.168.0.21:27017')
    mydb = client[db]
    mycol = mydb[col]
    return mycol

